# Maintainer: Justin Kromlinger <hashworks@archlinux.org>
pkgname=libzim
pkgver=8.1.1
# https://github.com/openzim/zim-testing-suite/releases
_testing_suite_commit=31ffbefd6699384d80e1f584b69b4321c843bc0c # v0.4
pkgrel=1
pkgdesc="Reference implementation of the ZIM specification by the openZIM project"
license=('GPL2')
arch=('loong64' 'x86_64')
depends=('xapian-core' 'zlib' 'xz' 'icu' 'zstd')
makedepends=('meson' 'gtest' 'git')
url='https://github.com/openzim/libzim'
source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/${pkgver}.tar.gz"
        "git+https://github.com/openzim/zim-testing-suite#commit=${_testing_suite_commit}")
sha256sums=('0d5ecb9b53c5511524a2726e5b6034541d3cab4afb2bc4c532da5a5fff45bcd9'
            'SKIP')

build() {
	cd "${pkgname}-${pkgver}"
	# https://github.com/openzim/libzim/issues/757
	arch-meson build \
		-Dtest_data_dir="${srcdir}/zim-testing-suite/data" \
		-Dcpp_std=c++14
	ninja -C build
}

check() {
	cd "${pkgname}-${pkgver}/build"
	SKIP_BIG_MEMORY_TEST=1 meson test
}

package() {
	install -Dm644 "${pkgname}-${pkgver}/COPYING" "$pkgdir/usr/share/licenses/$pkgname/COPYING"
	cd "${pkgname}-${pkgver}/build"
	DESTDIR="${pkgdir}" ninja install
}
